USE [NANS21V]
GO

/****** オブジェクト: Scalar Function [dbo].[Kumibun] スクリプト日付: 2014/04/17 15:27:19 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

USE [NANS21V]
GO
/****** オブジェクト:  UserDefinedFunction [dbo].[Kumibun]    スクリプト日付: 04/24/2014 14:45:05 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Kumibun]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[Kumibun]

GO
CREATE FUNCTION [dbo].[Kumibun]
(
	@HOST VARCHAR(10),
	@KUMIKYOGIFLG INT
)
RETURNS VARCHAR(10)
AS
BEGIN
	DECLARE @return varchar(10)
	IF @HOST !='' or @HOST != null
		SET @return = @HOST
BEGIN
	select @return = MSG.TITLE from TBL_WEB_USE_ID ID,TBL_WEB_USE_MSG MSG
	WHERE LOWER(TAGNAME)=LOWER('GroupingState') 
	AND ID.TAGID=MSG.TAGID
	AND MSG.XMLCODE=@KUMIKYOGIFLG
	--AND MSG.XMLCODE=999
END		
/*	ELSE IF @KUMIKYOGIFLG = '2'
		SET @return = '全済'
	ELSE 
		SET @return = '未組分'
*/
	RETURN @return
END
